﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Models;
using System.Data.SqlClient;

namespace BLL
{
    public class AddressManager
    {
        AddressService service = new AddressService();
        
        public bool add(Address address)
        {
            //调用新增方法
            return service.addadd(address);
        }
        public List<Address> get(int id)
        {
            List<Address> adds = new List<Address>();
            SqlDataReader reader = service.get(id);
            while (reader.Read())
            {
                adds.Add(new Address(
                    reader.GetInt32(0),
                    reader.GetString(1),
                    reader.GetString(2),
                    reader.GetDecimal(3),
                    reader.GetInt32(4),
                    reader.GetInt32(5)
                    ));
            }
            DBhelper.Close();
            return adds;
        }
        public bool update(Address address)
        {
            //调用修改方法
            return service.update(address);
        }
        //调用修改默认方法
        public bool uprule(int id)
        {
            return service.uprule(id);
        }
        //清除默认
        public bool upup()
        {
            return service.upup();
        }
        public bool del(int id)
        {
            //调用删除方法
            return service.del(id);
        }
    }
}
